{% extends 'job_apply_manage/job_apply.html' %}
{% load static %}

{% block content %}
    <div class="container">
        <h1 class="mb-4">我的申请记录</h1>

        {% if applications %}
            <div class="table-responsive">
                <table class="table table-hover">
                    <thead class="table-dark" style="background-color: #1e3c72;">
                    <tr>
                        <th>职位名称</th>
                        <th>公司</th>
                        <th>工作地点</th>
                        <th>薪资范围</th>
                        <th>申请时间</th>
                        <th>申请状态</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for application in applications %}
                        <tr>
                            <td>{{ application.job.title }}</td>
                            <td>{{ application.job.company }}</td>
                            <td>{{ application.job.location }}</td>
                            <td>{{ application.job.salary_range }}</td>
                            <td>{{ application.applied_at|date:'Y-m-d H:i' }}</td>
                            <td>
                                {% if application.status == 'pending' %}
                                    <span class="badge bg-warning">{{ application.get_status_display }}</span>
                                {% elif application.status == 'reviewing' %}
                                    <span class="badge bg-info">{{ application.get_status_display }}</span>
                                {% elif application.status == 'accepted' %}
                                    <span class="badge bg-success">{{ application.get_status_display }}</span>
                                {% elif application.status == 'rejected' %}
                                    <span class="badge bg-danger">{{ application.get_status_display }}</span>
                                {% endif %}
                            </td>
                        </tr>
                    {% endfor %}
                    </tbody>
                </table>
            </div>
            <a href="{% url 'job_apply:job_apply_list' %}" class="btn btn-primary ms-2"
               style="background-color: #1e3c72; border: none; padding: 8px 20px; border-radius: 4px; font-weight: bold;">
                <i class="fas fa-history"></i> 返回职位列表
            </a>
        {% else %}
            <div class="alert alert-info">
                <p class="mb-0">您还没有提交过职位申请。</p>
            </div>
            <a href="{% url 'job_apply:job_apply_list' %}" class="btn btn-primary"
               style="background-color: #1e3c72; border: none;">
                <i class="fas fa-search"></i> 浏览职位
            </a>
        {% endif %}
    </div>
{% endblock %}